// pages/hotsongs/hotsongs.js
let {getHotarts} = require('../../api/musict')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  async onLoad(options) {
    this.setData({
      id:options.id
    })
    console.log(this.data.id);
    let res = await getHotarts(this.data.id)
    console.log(res)
    this.setData({
      list:res.data.songs
    })
  },
  goPlayer(e){
    //获取当前点击歌曲的索引
    let index = e.currentTarget.dataset.playindex;
    //将当前的额播放列表存储到本地
    wx.setStorage({
          data:this.data.list,
          key:'playList',
          success(){
            //跳转到正在播放页面
            wx.reLaunch({
              url: '/pages/plays/plays?index='+index,
            })
          }
    })


  },




})